﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace UBlockly.Util
{
    /// <summary>
    /// 适应屏幕
    /// </summary>
    public static class AutoFilterScreen
    {
        static Vector2 AutoScale;
        static Vector2 constResolution = new Vector2(2048, 1536);

        public static void Init(Vector2 resolution)
        {
            AutoScale = new Vector2(resolution.x / constResolution.x, resolution.y / constResolution.y);
        }

        public static Vector2 GetResizeScale()
        {
            return AutoScale;
        }

        public static float GetXSpace(float x)
        {
            return x * AutoScale.x;
        }

        public static float GetYSpace(float y)
        {
            return y * AutoScale.y;
        }

        public static Vector2 GetVector(Vector2 v)
        {
            return new Vector2(v.x * AutoScale.x, v.y * AutoScale.y);
        }
        public static Vector3 GetVector(Vector3 v)
        {
            return GetVector((Vector2)v);
        }
    }
}
